import { ref, reactive } from 'vue'
import type { FormInstance, FormRules } from 'element-plus'
import FSMessage from '@/utils/message'

export default function () {
  const dialogVisible = ref(false)

  const rolesList = ref<any[]>()

  const ruleForm = ref({
    nickName: '',
    username: '',
    password: '',
    status: false,
    email: '',
    telephone: '',
    roles: []
  })
  const dialogOptions = ref({
    title: '新增用户',
    openType: 1 // 1 新增用户， 2 编辑用户
  })
  const rules = reactive<FormRules>({
    nickName: [
      { required: true, message: 'Please input Activity nickName', trigger: 'blur' },
      { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'blur' }
    ],
    username: [
      {
        required: true,
        message: 'Please select Activity zone',
        trigger: 'change'
      }
    ],
    password: [
      {
        required: true,
        message: 'Please select Activity password',
        trigger: 'change'
      }
    ],
    status: [
      { required: true, message: 'status必传', trigger: 'change' }
    ],
    roles: [
      { required: true, message: '请选择角色类型', trigger: 'change' }
    ]
  })
  return {
    rules,
    ruleForm,
    dialogVisible,
    dialogOptions,
    rolesList
  }
}
